import { ConfigModule } from "@nestjs/config";
import { isRunTimeDev, isRunTimeProd } from "../../const";

function getEnv(): string[] {
    let env = ".env";
    if (isRunTimeDev) {
        env = ".env.development";
    } else if (isRunTimeProd) {
        env = ".env.production";
    }
    console.log("当前: 加载环境变量", env);
    return [env];
}

const configModule = ConfigModule.forRoot({
    expandVariables: true,
    envFilePath: getEnv(),
});

export { configModule };
